import java.util.LinkedList;
import java.util.ListIterator;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-10-18  18:01
 */
public class Test {
    public static void main(String[] args) {
        MyLinkList myLinkList = new MyLinkList();
        myLinkList.addFirst(1);
        myLinkList.addLast(2);
        myLinkList.addLast(3);
        myLinkList.addLast(3);
        myLinkList.display();
        myLinkList.addIndex(1,99);
        myLinkList.display();
        myLinkList.removeAllKey(3);
        myLinkList.display();

        LinkedList<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        //顺序表打印的五种方法
        System.out.println(list);
        System.out.println("=================");
        for(int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + " ");
        }
        System.out.println();
        System.out.println("=================");
        for (Integer x: list) {
            System.out.print(x + " ");
        }
        System.out.println();
        System.out.println("=================");
        ListIterator<Integer> it = list.listIterator();
        while(it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        System.out.println();
        System.out.println("========反向打印=========");
        ListIterator<Integer> it1 = list.listIterator(list.size());
        while(it1.hasPrevious()) {
            System.out.print(it1.previous() + " ");
        }
        System.out.println();
    }
}
